interface DrawAPI {
    drawCircle(radius: number, x: number, y: number): void;
}

class RedCircle implements DrawAPI {
    public drawCircle(radius: number, x: number, y: number): void {
        console.log(`Drawing a red circle of radius ${radius} at (${x}, ${y})`);
    }
}

class GreenCircle implements DrawAPI {
    public drawCircle(radius: number, x: number, y: number): void {
        console.log(`Drawing a green circle of radius ${radius} at (${x}, ${y})`);
    }
}

abstract class Shape {
    protected drawAPI: DrawAPI;
    protected constructor(drawAPI: DrawAPI) {
        this.drawAPI = drawAPI;
    }
    public abstract draw(): void;
}

class Circle extends Shape {
    private x: number;
    private y: number;
    private radius: number;
    public constructor(x: number, y: number, radius: number, drawAPI: DrawAPI) {
        super(drawAPI);
        this.x = x;
        this.y = y;
        this.radius = radius;
    }
    public override draw(): void {
        this.drawAPI.drawCircle(this.radius, this.x, this.y);
    }
}

function main() {
    const redCircle: Shape = new Circle(10, 20, 30, new RedCircle());
    const greenCircle: Shape = new Circle(50, 60, 70, new GreenCircle());
    redCircle.draw();
    greenCircle.draw();
}

main();
